
package com.luck.pf.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;

import com.luck.pf.common.Constants;

/**
 * 说明:
 * Copyright: Copyright (c) 2010
 * @author zhangwenrui 2010-8-9 下午04:46:16
 * @version 1.0
 */
public class MyAuthenticationSuccessHandler extends
		SavedRequestAwareAuthenticationSuccessHandler {
	public void onAuthenticationSuccess(HttpServletRequest request,
            HttpServletResponse response, Authentication authentication)
            throws ServletException, IOException {
        HttpSession session = request.getSession();
        UserDetails userDetails = (UserDetails) authentication.getPrincipal();
        session.setAttribute(Constants.SESSION_LOGIN_NAME, userDetails.getUsername());
        super.onAuthenticationSuccess(request, response, authentication);
    }

}
